{include_core file="m/lib/header.html" center="center" title="修改账户信息"}
{if $edit_type == 'edit_password'}
<div class="phone">
<form action="{AnUrl('user/setting/password_save')}" id="js_submitBtn" method="post">
  <input type="hidden" name="edit_type" value="{$edit_type}">
  <div class="sale-list">
    <div class="repair-list clearfix">
	  <label><input class="phone-txt" placeholder="原密码" type="password" id="jsPassword" name="old_password"/></label>
    </div>
	<div class="repair-list clearfix">
	  <label><input class="phone-txt" placeholder="新密码" type="password" id="jsnewPassword" name="new_password"/></label>
    </div>
	<div class="repair-list clearfix">
	  <label><input class="phone-txt" placeholder="确认密码" type="password" id="jsrePassword" name="re_password"/></label>
    </div>
  </div>
  <div class="address-submit"><a href="javascript:void(0);">保存</a></div>
</form>
</div>
<script type="text/javascript">
$(function(){
  $('.address-submit').click(function(){
    var pass = $.trim($('#jsPassword').val());
    var newpass = $.trim($('#jsnewPassword').val());
    var repass = $.trim($('#jsrePassword').val());
    if(newpass == '') {
      mobileShowMsg('对不起，新密码不得为空');
      return ;
    }
    if(repass == '') {
      mobileShowMsg('对不起，确认密码不得为空');
      return ;
    }
    if(getStringLen(newpass) < 6) {
      mobileShowMsg('对不起，密码最少要6位字符');
      return ;
    }
    if(getStringLen(newpass) >= 20) {
      mobileShowMsg('对不起，密码最多要20位字符');
      return ;
    }
    if(newpass != repass) {
      mobileShowMsg('对不起，两次输入密码不一致');
      return ;
    }
    $.post(
      "{AnUrl('user/setting/password_save')}",
     { 'old_password':pass, 'new_password':newpass, 're_password':repass, 'edit_type':'edit_password' },
     function(data){
      if(data.info == 'error') {
        mobileShowMsg(data.msg);
        return;
      } else {
        $('#js_submitBtn').submit();
      }
     },'json');
  });
});
</script>
{elseif $edit_type == 'set_password'}
<div class="phone">
  <form action="{AnUrl('user/setting/password_save')}" id="js_submitBtn" method="post">
  <input type="hidden" name="edit_type" value="{$edit_type}">
  <div class="sale-list">
	<div class="repair-list clearfix">
	  <label><input class="phone-txt" placeholder="输入密码" type="password" id="jsnewPassword" name="new_password"/></label>
    </div>
	<div class="repair-list clearfix">
	  <label><input class="phone-txt" placeholder="确认密码" type="password" id="jsrePassword" name="re_password"/></label>
    </div>
  </div>
  <div class="address-submit"><a href="javascript:void(0);">保存</a></div>
  </form>
</div>
<script type="text/javascript">
$(function(){
  $('.address-submit').click(function(){
    var newpass = $.trim($('#jsnewPassword').val());
    var repass = $.trim($('#jsrePassword').val());
    if(newpass == '') {
      mobileShowMsg('对不起，新密码不得为空');
      return ;
    }
    if(repass == '') {
      mobileShowMsg('对不起，确认密码不得为空');
      return ;
    }
    if(getStringLen(newpass) < 6) {
      mobileShowMsg('对不起，密码最少要6位字符');
      return ;
    }
    if(getStringLen(newpass) >= 20) {
      mobileShowMsg('对不起，密码最多要20位字符');
      return ;
    }
    if(newpass != repass) {
      mobileShowMsg('对不起，两次输入密码不一致');
      return ;
    }
    $.post(
      "{AnUrl('user/setting/password_save')}",
     { 'new_password':newpass, 're_password':repass, 'edit_type':'set_password' },
     function(data){
      if(data.info == 'error') {
        mobileShowMsg(data.msg);
        return;
      } else {
        $('#js_submitBtn').submit();
      }
     },'json');
  });
})
</script>
{elseif $edit_type == 'edit_email' || $edit_type == 'set_email'}
<div class="mail">
  <div class="mail-box">
  	{if $edit_type == 'edit_email'}
  	<div class="mail-list">
	  <p>原安全邮箱：<span>{$user_info.email}</span></p>
	</div>  	
  	{/if}
  	<form action="{AnUrl('user/setting/email_bind')}" id="js_submitBtn" method="post">
		<div class="mail-onw">
		  <label><input class="phone-txt" placeholder="新安全邮箱" name="new_email" id="js_new_email"/></label>
		</div>
	</form>
  </div>
  <div class="address-submit" id="btnEmail"><a href="javascript:void(0);">保存</a></div>
</div>
<script type="text/javascript">
  $(function(){
    $('#btnEmail').click(function(){
        var new_email = $.trim($('#js_new_email').val());
        if(new_email == '') {
          mobileShowMsg('您输入的邮箱不能为空', 'error');
          return;
        }
        if(!checkStr(new_email, 'mail')) {
          mobileShowMsg('您输入的邮箱格式不正确', 'error');
          return;
        }
        $.post("{AnUrl('user/setting/email_bind')}",
              { new_email:new_email },
              function(data){
                if(data.info == 'error') {
                  mobileShowMsg(data.msg, 'error');
                  return;
                } else if(data.info == 'ok') {
                  $('#js_submitBtn').submit();
                }
              },'json'
          );

    });
  });
</script>
{elseif $edit_type == 'edit_mobile'}
<div class="phone phone2">
  <form action="{AnUrl('user/setting/check_sms')}" id="js_edit_mobile" method="post">
  <input type="hidden" value="edit" name="send_type" />
  <div class="sale-list">
    <div class="repair-list clearfix">
      <p>安全手机：{$user_info.mobile}</p>
    </div>
    <div class="repair-list clearfix">
      <p><input type="text" id="js_code" name="code" placeholder="验证码"/></p>
      <a class="phone-gain" href="javascript:void(0);" id="getCode" value="on">获取验证码</a>
    </div>
  </div>
  <div class="address-submit" id="edit_mobile"><a href="javascript:void(0);">下一步</a></div>
  </form>
</div>
<script type="text/javascript">
$(function(){
  $('#getCode').click(function(){
    // var mobile = $.trim($('#js_mobileM').val());
    // var codeNext = $('#js_codeM').parent().next();
      if($(this).attr('value') == 'on') {
      $.post(
          "{AnUrl('user/register/sendRegsms')}",
          { 'mobile':{$user_info.mobile}, 'send_type':'edit' },
          function(data){
            if(data.info == 'error') {
              mobileShowMsg(data.msg, 'error');
            } else {
              var time = 59;
              $('#getCode').html(time).attr('value', 'off');
              var Timer=setInterval(function(){
                if(time > 0){
                  time--;
                  $('#getCode').html(time).attr('value', 'off');
                } else {
                  $('#getCode').html('获取验证码').attr('value', 'on');
                  clearInterval(Timer);
                }
              },1000);
            }
          },'json');
      }
  });
  $('#edit_mobile').click(function(){
    var code = $.trim($('#js_code').val());
    if(code == '') {
      mobileShowMsg('手机验证码不能为空！');
      return;
    }
    $.post(
        "{AnUrl('user/setting/check_sms')}",
        { 'code':code, 'send_type':'edit' },
        function(data) {
          if(data.info == 'error') {
            mobileShowMsg(data.msg, 'error');
            return;
          } else {
            $('#js_edit_mobile').submit();
          }
        },'json');
  });
});
</script>
{elseif $edit_type == 'set_mobile'}
<div class="phone">
  <form action="{AnUrl('user/setting/check_sms')}" id="js_check_mobile" method="post">
  <input type="hidden" name="send_type" value="check" />
  <div class="sale-list">
    <div class="repair-list clearfix">
      <label><input class="phone-txt" placeholder="新安全手机" type="text" id="js_mobile" name="mobile"/></label>
    </div>
    <div class="repair-list clearfix">
      <p><input type="text" placeholder="验证码" id="js_code" name="code"/></p>
      <a class="phone-gain" href="javascript:void(0);" id="getCode" value="on">获取验证码</a>
    </div>
  </div>
  <div class="address-submit"  id="check_mobile"><a href="javascript:void(0);">保存</a></div>
</div>

<script type="text/javascript">
$(function(){
  $('#getCode').click(function(){
    var mobile = $.trim($('#js_mobile').val());
    if(mobile == '') {
      mobileShowMsg('手机号码不能为空！', 'error');
      return;
    }
    if(!checkStr(mobile, 'mobile')) {
      mobileShowMsg('手机号码的格式不正确！', 'error');
      return;
    }
    $.post(
        "{AnUrl('user/register/ajax_mobile')}",
        { mobile:mobile },
        function(data) {
          if(data.info == 'error') {
            mobileShowMsg(data.msg);
            return;
          } else {
            if($('#getCode').attr('value') == 'on') {
              var time = 59;
              $('#getCode').html(time).attr('value', 'off');
              var Timer=setInterval(function(){
                if(time > 0){
                  time--;
                  $('#getCode').html(time).attr('value', 'off');
                } else {
                  $('#getCode').html('获取验证码').attr('value', 'on');
                  clearInterval(Timer);
                }
              },1000);

              $.post(
                "{AnUrl('user/register/sendRegsms')}",
                { 'mobile':mobile, 'send_type':'check' },
                function(data){
                  if(data.info == 'error') {
                    mobileShowMsg(data.msg, 'error');
                  } else {
                    var time = 59;
                    $('#getCode').html(time).attr('value', 'off');
                    var Timer=setInterval(function(){
                      if(time > 0){
                        time--;
                        $('#getCode').html(time).attr('value', 'off');
                      } else {
                        $('#getCode').html('获取验证码').attr('value', 'on');
                        clearInterval(Timer);
                      }
                    },1000);
                  }
                },'json');
            }
          }
        },'json'
    );
  });

  $('#check_mobile').click(function(){
    var mobile = $.trim($('#js_mobile').val());
    var code = $.trim($('#js_code').val());
    if(mobile == '') {
      mobileShowMsg('手机号码不能为空！', 'error');
    }
    if(!checkStr(mobile, 'mobile')) {
      mobileShowMsg('手机号码的格式不正确！', 'error');
    }
    if(code == '') {
      mobileShowMsg('手机验证码不能为空！', 'error');
      return;
    }
    $.post(
        "{AnUrl('user/setting/check_sms')}",
        { 'code':code, 'mobile' : mobile, 'send_type':'check' },
        function(data) {
          if(data.info == 'error') {
            mobileShowMsg(data.msg, 'error');
            return;
          } else {
            $('#js_check_mobile').submit();
          }
        },'json');
  });

});
</script>
{/if}



{include_core file="m/lib/footer.html"}